package com.lc.datasource;

import com.alibaba.druid.pool.DruidDataSource;
import com.lc.config.annos.Autowired;
import com.lc.config.annos.Component;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author liuc
 * @date 2021/4/19
 * @description
 **/
@Component
public class MyDataSource {

    private static final DruidDataSource DRUID_DATA_SOURCE = new DruidDataSource();

    static {
        DRUID_DATA_SOURCE.setDriverClassName("com.mysql.cj.jdbc.Driver");
        DRUID_DATA_SOURCE.setUrl("jdbc:mysql://localhost:3306/bank");
        DRUID_DATA_SOURCE.setUsername("root");
        DRUID_DATA_SOURCE.setPassword("lc@123456..");
    }

    public Connection getConnection() throws SQLException {
        return DRUID_DATA_SOURCE.getConnection();
    }
}
